import { ObjCreate } from "../../common/ObjCreate";
import { ArenaCrossGroupMatchBattleCellRenderer } from "../cellRenderer/ArenaCrossGroupMatchBattleCellRenderer";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { Global } from "../../../../../com/gengine/global/Global";
import { SArenaCrossGroupBattles } from "../../../../../Message/Public/SArenaCrossGroupBattles";
import { SArenaCrossGroupBattleEnd } from "../../../../../Message/Public/SArenaCrossGroupBattleEnd";
import { SArenaCrossGroupBattle } from "../../../../../Message/Public/SArenaCrossGroupBattle";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
type int = number;
//class ArenaCrossGroupMatchSchedule
    
    export  class ArenaCrossGroupMatchSchedule /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStage);
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, 544, 483, this);
            this._tileList = ObjCreate.createTileList(5, 5, 540, 480, this);
            this._tileList.columnWidth = 540;
            this._tileList.rowHeight = 96;
            this._tileList.verticalGap = 0;
            this._tileList.setStyle("cellRenderer", ArenaCrossGroupMatchBattleCellRenderer);
            this._tfNoResult = ObjCreate.createTextField(Language.getString(44251), 235, 243, 200, 20, this, GlobalStyle.textFormat6);
            this._tfNoResult.visible = false;
            return;
        }

        /* internal  */onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            this.getData();
            return;
        }

        /* internal  */getData(): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaCrossGetGroupBattles, this._groupId));
            return;
        }

        public get groupId(): int
        {
            return this._groupId;
        }

        public set groupId(arg1: int)
        {
            this._groupId = arg1;
            if (Global.stage.contains(this)) 
            {
                this.getData();
            }
            return;
        }

        public updateGroupBattles(arg1: SArenaCrossGroupBattles): void
        {
            this._groupBattles = arg1.groupBattles;
            this.updateView();
            return;
        }

        public updateGroupBattleEnd(arg1: SArenaCrossGroupBattleEnd): void
        {
            var loc1=0;
            var loc2=null;
            if (this._groupBattles) 
            {
                loc1 = 0;
                while (loc1 < this._groupBattles.length) 
                {
                    loc2 = this._groupBattles[loc1] as SArenaCrossGroupBattle;
                    if (loc2.arenaId == arg1.arenaId) 
                    {
                        loc2.arenaId = 0;
                    }
                    ++loc1;
                }
                this.updateView();
            }
            return;
        }

        /* internal  */updateView(): void
        {
            this._tileList.dataProvider = new DataProvider(this._groupBattles);
            this._tileList.drawNow();
            var loc1=this._tileList.dataProvider.length > 0;
            this._tileList.visible = loc1;
            this._tfNoResult.visible = !loc1;
            return;
        }

        /* internal */ /* var */_groupId: int=0;

        /* internal */ /* var */_tileList: GTileList;

        /* internal */ /* var */_tfNoResult: Object /* flash.text.TextField */;

        /* internal */ /* var */_groupBattles: Array<any>;
    }
